<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="../Master/adminMaster.xhtml">
            <ui:define name="page-content">

                <section class="grid_12" id="dashtabs">
                    <div class="box-header">
                        Department Report
                        <ul class="controls">
                            <li><a href="#dashtabs-pages" class="tooltip" title="Pages"><img src="../Master/img/icons/16/home_16.png"/></a></li>
                            <c:forEach items="#{departmentMBean.departments}" var="de">
                                <li><a href="#dashtabs-comments-#{de.departmentID}" class="tooltip" title="#{de.departmentName}"><img src="../Master/img/icons/16/label_16.png"/></a></li>
                            </c:forEach>
                        </ul>
                    </div>

                    <div id="dashtabs-pages" class="box-content no-padding">
                        <f:view>
                            <h:form id="form" prependId="false">

                                <p:dataTable var="item" value="#{departmentReportMBean.deReports}" id="deReportDataTable" editable="true"
                                             paginator="true" rows="10" style="width: 100% !important;" paginatorPosition="bottom" 
                                             rowsPerPageTemplate="5,10,15" styleClass="table no-border"
                                             emptyMessage="No complaints found with given criteria" filteredValue="#{departmentReportMBean.filteredDeReports}"
                                             widgetVar="deReportTable">

                                    <f:facet name="header">  
                                        <p:outputPanel style="float:right;">  
                                            <h:outputText value="Search all fields:" />  
                                            <p:inputText id="globalFilter" onkeyup="deReportTable.filter()" style="width:150px" />  
                                        </p:outputPanel>  
                                    </f:facet>

                                    <p:column headerText="Complaint Category" 
                                              sortBy="#{item.value.categoryID.categoryName}" 
                                              filterBy="#{item.value.categoryID.categoryName}" 
                                              filterMatchMode="contains">
                                        <h:outputText value="#{item.value.categoryID.categoryName}" />
                                    </p:column>

                                    <p:column headerText="No/Name Employee" 
                                              sortBy="#{item.value.membersID.membersName}"
                                              filterBy="#{item.value.membersID.membersName}" 
                                              filterMatchMode="contains" >
                                        <h:outputText value="#{item.value.membersID.membersName}" />
                                    </p:column>

                                    <p:column headerText="Date Of Lodging" sortBy="#{item.value.complaintCreateDate}">
                                        <h:outputText value="#{item.value.complaintCreateDate}">
                                            <f:convertDateTime pattern="dd/MM/yyyy HH:ss"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="Date Of Closing" sortBy="#{item.value.complaintCloseDate}">
                                        <h:outputText value="#{item.value.complaintCloseDate}">
                                            <f:convertDateTime pattern="dd/MM/yyyy  HH:ss"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column headerText="Technician"
                                              sortBy="#{item.key.get(0).membersID.membersName}"
                                              filterBy="#{item.key.get(0).membersID.membersName}" 
                                              filterMatchMode="contains" >
                                        <h:outputText value="#{item.key.get(0).membersID.membersName}" />
                                    </p:column>

                                    <p:column headerText="Status" 
                                              sortBy="#{item.value.complaintStatus}"
                                              filterBy="#{item.value.complaintStatus}" 
                                              filterMatchMode="contains" >
                                        <h:outputText value="Done" rendered="#{item.value.complaintStatus == 0}" />
                                        <h:outputText value="Pending" rendered="#{item.value.complaintStatus == 1}" />
                                    </p:column>

                                    <p:column headerText="Time Solved" 
                                              filterMatchMode="contains" >
                                        <h:outputText value="#{item.key.get(1)}" />
                                    </p:column>

                                </p:dataTable>

                            </h:form>
                        </f:view>
                    </div>

                    <c:forEach items="#{departmentMBean.departments}" var="de">
                        <div id="dashtabs-comments-#{de.departmentID}" class="box-content no-padding">

                            <p:dataTable var="item" value="#{departmentReportMBean.getDeReportsByDepartment(de)}" 
                                         editable="true" paginatorPosition="bottom"
                                         paginator="true" rows="10" style="width: 100% !important;"
                                         rowsPerPageTemplate="5,10,15" styleClass="table no-border"
                                         emptyMessage="No article found with given criteria" widgetVar="deReportTable">

                                <f:facet name="header">  
                                    #{de.departmentName}  
                                </f:facet> 

                                <f:facet name="header">  
                                    <p:outputPanel style="float:right;">  
                                        <h:outputText value="Search all fields:" />  
                                        <p:inputText id="globalFilter" onkeyup="deReportTable.filter()" style="width:150px" />  
                                    </p:outputPanel>  
                                </f:facet>

                                <p:column headerText="Complaint Category" 
                                          sortBy="#{item.value.categoryID.categoryName}" 
                                          filterBy="#{item.value.categoryID.categoryName}" 
                                          filterMatchMode="contains">
                                    <h:outputText value="#{item.value.categoryID.categoryName}" />
                                </p:column>

                                <p:column headerText="No/Name Employee" 
                                          sortBy="#{item.value.membersID.membersName}"
                                          filterBy="#{item.value.membersID.membersName}" 
                                          filterMatchMode="contains" >
                                    <h:outputText value="#{item.value.membersID.membersName}" />
                                </p:column>

                                <p:column headerText="Date Of Lodging" sortBy="#{item.value.complaintCreateDate}">
                                    <h:outputText value="#{item.value.complaintCreateDate}">
                                        <f:convertDateTime pattern="dd/MM/yyyy HH:ss"/>
                                    </h:outputText>
                                </p:column>

                                <p:column headerText="Date Of Closing" sortBy="#{item.value.complaintCloseDate}">
                                    <h:outputText value="#{item.value.complaintCloseDate}">
                                        <f:convertDateTime pattern="dd/MM/yyyy  HH:ss"/>
                                    </h:outputText>
                                </p:column>

                                <p:column headerText="Technician" 
                                          sortBy="#{item.key.get(0).membersID.membersName}"
                                          filterBy="#{item.key.get(0).membersID.membersName}" 
                                          filterMatchMode="contains" >
                                    <h:outputText value="#{item.key.get(0).membersID.membersName}" />
                                </p:column>

                                <p:column headerText="Status"
                                          sortBy="#{item.value.complaintStatus}"
                                          filterBy="#{item.value.complaintStatus}" 
                                          filterMatchMode="contains" >
                                    <h:outputText value="Done" rendered="#{item.value.complaintStatus == 0}" />
                                    <h:outputText value="Pending" rendered="#{item.value.complaintStatus == 1}" />
                                </p:column>

                                <p:column headerText="Time Solved"
                                          filterMatchMode="contains" >
                                    <h:outputText value="#{item.key.get(1)}" />
                                </p:column>

                            </p:dataTable>

                        </div>
                    </c:forEach>
                </section>
                <br class="cl" />

            </ui:define>
        </ui:composition>
    </h:body>
</html>

